/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frontera;

import control.Graficas;
import entidad.Persistencia;
import javax.swing.JPanel;

/**
 *
 * @author Admin
 */
public class PanelHistoriograma extends javax.swing.JPanel {

    /**
     * Creates new form PanelHistoriograma
     */
    public PanelHistoriograma() {
        initComponents();
        jPanel_Grafico.add(new Graficas().Graficar(Persistencia.getInstance().getHistorico(), 1, "Historico"));
    }
    
    public void cambiarPanel(JPanel panel) {
        jPanel_Grafico.setVisible(false);
        jPanel_Grafico.removeAll();
        jPanel_Grafico.add(panel);
        jPanel_Grafico.setSize(panel.getPreferredSize());
        jPanel_Grafico.setVisible(true);
        this.setSize(this.getPreferredSize());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup_Variables = new javax.swing.ButtonGroup();
        jRadioButton_Temperatura = new javax.swing.JRadioButton();
        jRadioButton_Pluviosidad = new javax.swing.JRadioButton();
        jRadioButton_Pres_Atmosferica = new javax.swing.JRadioButton();
        jPanel_Grafico = new javax.swing.JPanel();

        setBorder(javax.swing.BorderFactory.createTitledBorder("Historico"));

        buttonGroup_Variables.add(jRadioButton_Temperatura);
        jRadioButton_Temperatura.setSelected(true);
        jRadioButton_Temperatura.setText("Temperatura");
        jRadioButton_Temperatura.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton_TemperaturaActionPerformed(evt);
            }
        });

        buttonGroup_Variables.add(jRadioButton_Pluviosidad);
        jRadioButton_Pluviosidad.setText("Pluviosidad");
        jRadioButton_Pluviosidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton_PluviosidadActionPerformed(evt);
            }
        });

        buttonGroup_Variables.add(jRadioButton_Pres_Atmosferica);
        jRadioButton_Pres_Atmosferica.setText("Presión Atmosferica");
        jRadioButton_Pres_Atmosferica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton_Pres_AtmosfericaActionPerformed(evt);
            }
        });

        jPanel_Grafico.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel_Grafico.setLayout(new java.awt.BorderLayout());

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jRadioButton_Temperatura)
                        .addGap(18, 18, 18)
                        .addComponent(jRadioButton_Pluviosidad)
                        .addGap(18, 18, 18)
                        .addComponent(jRadioButton_Pres_Atmosferica)
                        .addGap(0, 84, Short.MAX_VALUE))
                    .addComponent(jPanel_Grafico, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButton_Temperatura)
                    .addComponent(jRadioButton_Pluviosidad)
                    .addComponent(jRadioButton_Pres_Atmosferica))
                .addGap(18, 18, 18)
                .addComponent(jPanel_Grafico, javax.swing.GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jRadioButton_TemperaturaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_TemperaturaActionPerformed
        cambiarPanel(new Graficas().Graficar(Persistencia.getInstance().getHistorico(), 1, "Historico"));
    }//GEN-LAST:event_jRadioButton_TemperaturaActionPerformed

    private void jRadioButton_PluviosidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_PluviosidadActionPerformed
        cambiarPanel(new Graficas().Graficar(Persistencia.getInstance().getHistorico(), 3, "Historico"));
    }//GEN-LAST:event_jRadioButton_PluviosidadActionPerformed

    private void jRadioButton_Pres_AtmosfericaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton_Pres_AtmosfericaActionPerformed
        cambiarPanel(new Graficas().Graficar(Persistencia.getInstance().getHistorico(), 2, "Historico"));
    }//GEN-LAST:event_jRadioButton_Pres_AtmosfericaActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup_Variables;
    private javax.swing.JPanel jPanel_Grafico;
    private javax.swing.JRadioButton jRadioButton_Pluviosidad;
    private javax.swing.JRadioButton jRadioButton_Pres_Atmosferica;
    private javax.swing.JRadioButton jRadioButton_Temperatura;
    // End of variables declaration//GEN-END:variables
}
